home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 564 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.6 KB  |  47 lines

  1. Path: chronicle.mti.sgi.com!austern
  2. From: oliva@grande.dcc.unicamp.br (Alexandre Oliva)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Q: default constructor for fundamental types?
  5. Date: 27 Feb 1996 10:40:34 PST
  6. Organization: DCC - UNICAMP - Campinas, SP, Brazil
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <orn365ieob.fsf@grande.dcc.unicamp.br>
  9. NNTP-Posting-Host: isolde.mti.sgi.com
  10. X-Original-Date: 27 Feb 1996 01:19:00 -0300
  11. X-Newsreader: Gnus v5.1
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBVAwUBMTNQNUy4NqrwXLNJAQE5RgIArZcJcGK0s9K+IQwATK1K2gFF0TzLWI+r
  14.     EyfB2VCpNLu85CqldSHFckcuBkpWKauvGcdu5G0i1iGkCoVUIz6TRg==
  15.     =dEeg
  16. Originator: austern@isolde.mti.sgi.com
  17.  
  18. Dirk Herrmann writes:
  19.  
  20. > Sorry if this has been discussed before.
  21. > When using templates, it appears that there should be
  22. > default constructors for the fundamental data types.
  23.  
  24. You  need  not invoke  default    constructors explicitly.  By  simply
  25. removing ": t()" from the following code snippet, it will compile fine
  26. even for X<int>.  For types which  have a default constructor, it will
  27. be invoked, as it should.
  28.  
  29. template <class T>
  30. class X {
  31. private:
  32.   T t;
  33. public:
  34.   X() /* : t() */ {}
  35. };
  36. -- 
  37. Alexandre Oliva
  38. oliva@dcc.unicamp.br
  39. Universidade Estadual de Campinas, S~ao Paulo, Brasil
  40. ---
  41. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  42.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  43.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  44.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  45.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  46. ]
  47.